//
//  HLiveLeftAudienceView.m
//  linktuIOS
//
//  Created by hejunsong on 2017/1/13.
//  Copyright © 2017年 tianxie. All rights reserved.
//

#import "HLiveLeftAudienceView.h"
#import "Masonry.h"
#import "AudienceListCell.h"
@interface HLiveLeftAudienceView()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong) UITableView *tableView;

@end


@implementation HLiveLeftAudienceView


-(instancetype)init
{
    if(self = [super init])
    {
        [self makeUI];
        
    }
    return self;
}

-(instancetype)initWithFrame:(CGRect)frame
{
    if(self = [super initWithFrame:frame])
    {
        [self makeUI];
        
        
    }
    return self;
}

-(void)makeUI
{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 0, 0) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    _tableView.rowHeight = 50;
    _tableView.showsVerticalScrollIndicator = NO;
    _tableView.backgroundColor = [UIColor clearColor];
//    _tableView.backgroundColor = [UIColor redColor];
    [self addSubview:_tableView];
    [_tableView registerNib:[UINib nibWithNibName:@"AudienceListCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"audiencelist"];
    [_tableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(0);
        make.right.mas_equalTo(self.mas_right).offset(0);
        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
        make.top.mas_equalTo(self.mas_top).offset(0);
    }];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.viewmodel.viewerModelArray.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    AudienceListCell *cell = [tableView dequeueReusableCellWithIdentifier:@"audiencelist"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
//    cell.model = self.viewmodel.viewerModelArray[indexPath.row];
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(self.delegate && [self.delegate respondsToSelector:@selector(leftAudienceView:index:)])
    {
        [self.delegate leftAudienceView:self index:indexPath.row];
        
    }


}


-(void)relaodData
{
    [self.tableView reloadData];
}
-(void)dealloc
{
    NSLog(@"dealloc --HLiveLeftAudienceView");
    
}
@end
